//
//  RecomPageView.m
//  BosidengIphone
//
//  Created by  on 12-1-17.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import "RecomPageView.h"
#import "RecomView.h"
#import "MyShowData.h"

@implementation RecomPageView
@synthesize recomDatas;
@synthesize pageIndex;
@synthesize requestQueue;
@synthesize mainViewController;

- (void)initAllSubView {
    viewCount = 3;
    recomViews = [[NSMutableArray arrayWithCapacity:viewCount] retain];
    
    int x = 0;
    for (int i = 0; i < viewCount; i++) {
        x = i * (96 + 8);
        CGRect subFrame = CGRectMake(x, 0, 96, 96);
        RecomView *view = [[RecomView alloc] initWithFrame:subFrame];
        [recomViews addObject:view];
        [self addSubview:view];
        [view release];
    }
}

- (id)init {
    self = [super init];
    if (self) {
        [self initAllSubView];
    }
    return self;
}

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self initAllSubView];
    }
    return self;
}

- (void)dealloc {
    self.mainViewController = nil;
    [recomDatas release];
    [requestQueue release];
    [recomViews release];
    [super dealloc];
}

- (void)loadData {
    int i = 0, index = 0;
    for (RecomView *view in recomViews) {
        index = pageIndex * viewCount + i;
        if (index < [recomDatas count]) {
            MyShowData *data = [recomDatas objectAtIndex:index];
            [view loadData:data andRequestQueue:requestQueue viewController:mainViewController];
        }
        i++;
    }
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
}
*/

@end
